#!/bin/sh

set -e

PUBLISH=$1

echo "Deploying to heroku (PUBLISH=$PUBLISH)..."

[ -e dist/heroku ] && rm -rf dist/heroku
cp -R dist/mountebank dist/heroku
cp Procfile dist/heroku

(
cd dist/heroku
dpl --provider=heroku --api-key=$HEROKU_API_KEY --app=mountebank-dev --skip-cleanup

if [ "$PUBLISH" = "true" ]; then
    dpl --provider=heroku --api-key=$HEROKU_API_KEY --app=mountebank --skip-cleanup
fi
cd ..
)
